




var _oMessages =
{
sNoSelectedAttributes:	LOCID_CRTMAP_MUSTSELECT
};






var _oConst =
{
sSourceGridName:	"sourceAttributesGrid",
sTargetGridName:	"targetAttributesGrid"
}











function CreateMappingJsWindowOnLoad()
{
sourceAttributesGrid.OnBeforeFormLoad = onAttributeDblClick;
sourceAttributesGrid.SetParameter("disableDblClick", "0");
targetAttributesGrid.OnBeforeFormLoad = onAttributeDblClick;
targetAttributesGrid.SetParameter("disableDblClick", "0");
}

window.attachEvent('onload', CreateMappingJsWindowOnLoad);










function cancel()
{
window.returnValue = null;
window.close();
}






function applychanges()
{
if (validateParameters())
{
var oResult = new Object();

oResult.sMappingXml	= getMappingXml();
window.returnValue	= oResult;

window.close();
}
}










function getMappingXml()
{
var sSourceAttribute = getSelected(_oConst.sSourceGridName);
var sTargetAttribute = getSelected(_oConst.sTargetGridName);

var oDataXml = createXmlDoc(_oTags.attributemap);

addTextXmlNode(oDataXml, _oTags.sourceattributename, sSourceAttribute[0]);
addTextXmlNode(oDataXml, _oTags.targetattributename, sTargetAttribute[0]);
addTextXmlNode(oDataXml, _oTags.entitymapid, _sMappingId);

return convertXmlDocToString(oDataXml);
}










function validateParameters()
{
var sSourceAttribute = getSelected(_oConst.sSourceGridName);
var sTargetAttribute = getSelected(_oConst.sTargetGridName);

if (sSourceAttribute.length != 1 || sTargetAttribute.length != 1)
{
alert(_oMessages.sNoSelectedAttributes);
return false;
}

return true;
}










function onAttributeDblClick()
{
event.returnValue = false;
}
